<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<script src="__INDEX__/js/jquery-1.8.3.min.js"></script>
<link rel="stylesheet" href="__INDEX__/js/skin/layer.css">
<link rel="stylesheet" href="__ADMIN__/css/pintuer.css">
<link rel="stylesheet" href="__ADMIN__/css/admin.css">

<script src="__INDEX__/js/layer.js"></script>
<script src="__ADMIN__/js/jquery.js"></script>
<script src="__ADMIN__/js/pintuer.js"></script>

</head>
<body>

  <div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 公告通知</strong></div>
    <div class="padding border-bottom">
        <ul class="search" style="padding-left:10px;">
            <li> <a class="button border-main icon-plus-square-o" href="add">添加公告通知</a> </li>
        </ul>
    </div>
    <table class="table table-hover text-center">
      <tr>
        <th>ID</th>
        <th>公告名称</th>
        <th>公告内容</th>
        <th>公告链接</th>
        <th>公告排序</th>
        <th>状态</th>
        <th>浏览次数</th>
        <th width="180">创建时间</th>
        
        <th width="200">操作</th>
      </tr>
        {volist name="data" id="vo"}
         <tr>
            <td>{$vo.id}</td>
            <td title="{$vo.titles}">{$vo.titles|mb_substr=0,10}</td>
            <td ><textarea cols="50" rows="5">{$vo.contents} </textarea></td>
             <!--<td >{$vo.contents|mb_substr=0,30}</td>-->
            <td>{$vo.link}</td>
            <td>
                {if condition="$vo.sort eq ''"}
                     <input type="text" onchange="change(this)" name="sort" style="width: 30px;" value="{$vo.sort}"></td>
                {else /}
                    <input type="text" onchange="change(this)" name="sort" style="width: 30px;" value="{$vo.sort}"></td>
                {/if}

            <td>{$vo.status == 1?'启用':'禁用'}</td>
            <td>{$vo.frequency}</td>
            <td>{$vo.create_time}</td>
            
            <td>
                <div class="button-group">
                    <a class="button border-main" href="{:url('admin/nots/edi',['id'=>$vo.id])}"><span class="icon-edit"></span> 修改</a>
                    <a class="button border-red" href="javascript:void(0)" onclick=" del({$vo['id']})"><span class="icon-trash-o"></span> 删除</a>
                 </div>
            </td>
        </tr>
        {/volist}
      <tr>
        <td colspan="9">
            {$data->render()}
        </td>
      </tr>
    </table>
  </div>

<script type="text/javascript">
    function change(obj) {
        var val = $(obj).val();
        var id = $(obj).parent().siblings(":first").html();
        $.ajax({
            type: 'POST',
            url: 'change',
            data:{'id':id,'sort':val},
            dataType: 'json',
            success: function(data){
                alert(data);
            },
            error:function(data) {
               alert('服务器错误');
            },
        });
    }



//单个删除
function del(id){
  if(confirm("您确定要删除吗?")){
        $.ajax({
            type : "POST",
            url : "{:url('admin/nots/del')}",
            data : {'id':id},
            dataType :'json',
            success:function (data) {
                alert(data);
                location.reload(true);
                // layer.msg(data, function(){
                //       location.reload(true);
                //     });


            },
            error:function (data) {
                alert('服务器内部错误');
            },
        })
  }else{
      return false;
    }
}
</script>
</body>
</html>